//
//  BIDHouseListViewController.m
//  zkwy
//
//  Created by mal on 2016/11/4.
//  Copyright © 2016年 mal. All rights reserved.
//

#import "BIDHouseListViewController.h"
#import "AppDelegate+StaticMethod.h"
#import "BIDPayListViewController.h"

@interface BIDHouseListViewController ()
{
    NSArray *_dataSourceArr;
}
@end

@implementation BIDHouseListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"房屋列表";
    _dataSourceArr = [[NSArray alloc] initWithArray:[AppDelegate getBindingHouse]];
    self.tableView.tableFooterView = [[UIView alloc] init];
    //
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(backBtnHandler)];
    self.navigationItem.backBarButtonItem = barButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataSourceArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"identifier";
    NSUInteger row = indexPath.row;
    NSDictionary *dic = _dataSourceArr[row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if(!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    NSString *strTitle = dic[@"address"];
    cell.textLabel.text = strTitle;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSUInteger row = indexPath.row;
    NSDictionary *dic = _dataSourceArr[row];
    UIViewController *vc = nil;
    //费用列表
    BIDPayListViewController *payListVC = [[BIDPayListViewController alloc] initWithNibName:@"BIDPayListViewController" bundle:nil];
    payListVC.houseCode = dic[@"houseCode"];
    payListVC.feeCode = dic[@"feeCode"];
    vc = payListVC;
    [self.navigationController pushViewController:vc animated:YES];
}

@end
